<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        body {
            background-color: gray;
        }

        .container {
            margin-bottom: 1000px;
        }

        .modal {
            width: 100px;
            height: 100px;
            background-color: brown;
            position: fixed;
            top: calc(50% - 50px);
            left: calc(50% - 50px);
            display: none;
        }
    </style>
</head>

<body>
    <div class="container">
        <button class="btn">打开蒙层</button>
    </div>
    <div class="modal">蒙层
        <button class="btn2">关闭</button>
    </div>
    <script>
        const btn = document.querySelector('.btn')
        const btn2 = document.querySelector('.btn2')
        const modal = document.querySelector('.modal')

        btn.addEventListener('click', () => {
            window.addEventListener('wheel', scroll, {
                passive: false
            })
            modal.style.display = 'block'
        })
        btn2.addEventListener('click', () => {
            modal.style.display = 'none'
            window.removeEventListener('wheel', scroll)
        })
        function scroll(e) {
            e.preventDefault()
        }
    </script>
</body>

</html>